<template>
  <div class="sub">
    <h3>当前count的值:{{ count }}</h3>
    <button @click="handleSub">-1</button>
    <button @click="handleSubN">-n</button>
  </div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
export default {
  data () {
    return {
    }
  },
  created () {
  },
  computed: {
    ...mapState(['count'])
  },
  methods: {
    ...mapMutations(['sub', 'sub2']),
    // 可以直接使用mutation中的方法 直接调用 可以不用定义handleSub
    handleSub () {
      this.sub()
    },
    handleSubN () {
      this.sub2(3)
    }

  }
}
</script>

<style scoped lang="scss">
</style>
